home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / edit / thesrc20.zip / comm5.c < prev    next >
C/C++ Source or Header  |  1995-01-26  |  33KB  |  982 lines

  1. /***********************************************************************/
  2. /* COMM5.C - Commands T-Z                                              */
  3. /* This file contains all commands that can be assigned to function    */
  4. /* keys or typed on the command line.                                  */
  5. /***********************************************************************/
  6. /*
  7.  * THE - The Hessling Editor. A text editor similar to VM/CMS xedit.
  8.  * Copyright (C) 1991-1995 Mark Hessling
  9.  *
  10.  * This program is free software; you can redistribute it and/or
  11.  * modify it under the terms of the GNU General Public License as
  12.  * published by the Free Software Foundation; either version 2 of
  13.  * the License, or any later version.
  14.  *
  15.  * This program is distributed in the hope that it will be useful,
  16.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  18.  * General Public License for more details.
  19.  *
  20.  * You should have received a copy of the GNU General Public License
  21.  * along with this program; if not, write to:
  22.  *
  23.  *    The Free Software Foundation, Inc.
  24.  *    675 Mass Ave,
  25.  *    Cambridge, MA 02139 USA.
  26.  *
  27.  *
  28.  * If you make modifications to this software that you feel increases
  29.  * it usefulness for the rest of the community, please email the
  30.  * changes, enhancements, bug fixes as well as any and all ideas to me.
  31.  * This software is going to be maintained and enhanced as deemed
  32.  * necessary by the community.
  33.  *
  34.  * Mark Hessling                     email: M.Hessling@gu.edu.au
  35.  * 36 David Road                     Phone: +61 7 849 7731
  36.  * Holland Park                      Fax:   +61 7 875 5314
  37.  * QLD 4121
  38.  * Australia
  39.  */
  40.  
  41. /*
  42. $Id: comm5.c 2.0 1995/01/26 16:30:03 MH Release MH $
  43. */
  44.  
  45. #include <stdio.h>
  46.  
  47. #include "the.h"
  48. #include "proto.h"
  49.  
  50. /*#define DEBUG 1*/
  51. /*man-start*********************************************************************
  52. COMMAND
  53.      tabpre - switch between FILEAREA and PREFIX area
  54.  
  55. SYNTAX
  56.      tabpre
  57.  
  58. DESCRIPTION
  59.      The TABPRE command switches the focus of the editor from the
  60.      FILEAREA to the PREFIX area and vice versa, depending
  61.      on which window is currently active.
  62.  
  63.      This command can only be used by assigning it to a function key.
  64.  
  65.      This command will be removed in a future version.
  66.  
  67. COMPATIBILITY
  68.      XEDIT: N/A
  69.      KEDIT: Equivalent of SOS LEFTEDGE and SOS PREFIX
  70.  
  71. SEE ALSO
  72.      SOS LEFTEDGE, SOS PREFIX
  73.  
  74. STATUS
  75.      Complete.
  76. **man-end**********************************************************************/
  77. #ifdef PROTO
  78. short Tabpre(CHARTYPE *params)
  79. #else
  80. short Tabpre(params)
  81. CHARTYPE *params;
  82. #endif
  83. /***********************************************************************/
  84. {
  85. /*-------------------------- external data ----------------------------*/
  86.  extern short prefix_width;
  87. /*--------------------------- local data ------------------------------*/
  88.  short rc=RC_OK;
  89. /*--------------------------- processing ------------------------------*/
  90. #ifdef TRACE
  91.  trace_function("comm5.c:   Tabpre");
  92. #endif
  93. /*---------------------------------------------------------------------*/
  94. /* No arguments are allowed; error if any are present.                 */
  95. /*---------------------------------------------------------------------*/
  96.  if (strcmp(params,"") != 0)
  97.    {
  98.     display_error(1,(CHARTYPE *)params,FALSE);
  99. #ifdef TRACE
  100.     trace_return();
  101. #endif
  102.     return(RC_INVALID_OPERAND);
  103.    }
  104. /*---------------------------------------------------------------------*/
  105. /* If the cursor is in the command line or there is no prefix on, exit.*/
  106. /*---------------------------------------------------------------------*/
  107.  if (CURRENT_VIEW->current_window == WINDOW_COMMAND
  108.  ||  !CURRENT_VIEW->prefix)
  109.    {
  110. #ifdef TRACE
  111.     trace_return();
  112. #endif
  113.     return(RC_OK);
  114.    }
  115.  if (CURRENT_VIEW->current_window == WINDOW_MAIN)
  116.     rc = Sos_prefix("");
  117.  else
  118.     rc = Sos_leftedge("");
  119. #ifdef TRACE
  120.  trace_return();
  121. #endif
  122.  return(rc);
  123. }
  124. /*man-start*********************************************************************
  125. COMMAND
  126.      text - simulate keyboard entry of characters
  127.  
  128. SYNTAX
  129.      TEXT text
  130.  
  131. DESCRIPTION
  132.      The TEXT command simulates the entry of characters from the
  133.      keyboard. This command is actually called when you enter text
  134.      from the keyboard.
  135.  
  136. COMPATIBILITY
  137.      XEDIT: N/A
  138.      KEDIT: Compatible.
  139.             Does not allow trailing spaces in text.
  140.  
  141. STATUS
  142.      Complete.
  143. **man-end**********************************************************************/
  144. #ifdef PROTO
  145. short Text(CHARTYPE *params)
  146. #else
  147. short Text(params)
  148. CHARTYPE *params;
  149. #endif
  150. /***********************************************************************/
  151. {
  152. /*------------------------- external data -----------------------------*/
  153.  extern CHARTYPE *rec;
  154.  extern LENGTHTYPE rec_len;
  155.  extern CHARTYPE *cmd_rec;
  156.  extern unsigned short cmd_rec_len;
  157.  extern bool INSERTMODEx;
  158.  extern bool prefix_changed;
  159.  extern CHARTYPE *pre_rec;
  160.  extern unsigned short pre_rec_len;
  161.  extern bool readonly;
  162.  extern short prefix_width;
  163.  extern VIEW_DETAILS *vd_mark;
  164. /*--------------------------- local data ------------------------------*/
  165.  register short i=0;
  166.  CHARTYPE real_key=0;
  167.  chtype chtype_key=0;
  168.  unsigned short y=0,x=0;
  169.  short len_params=0;
  170.  short rc=RC_OK;
  171.  short off=0;
  172. #if defined(USE_EXTCURSES)
  173.  ATTR attr=0;
  174. #else
  175.  chtype attr=0;
  176. #endif
  177.  bool need_to_build_screen=FALSE;
  178. /*--------------------------- processing ------------------------------*/
  179. #ifdef TRACE
  180.  trace_function("comm5.c:   Text");
  181. #endif
  182. /*---------------------------------------------------------------------*/
  183. /* If running in read-only mode, do not allow any text to be entered   */
  184. /* in the main window.                                                 */
  185. /*---------------------------------------------------------------------*/
  186.  if (readonly && CURRENT_VIEW->current_window == WINDOW_MAIN)
  187.    {
  188.     display_error(56,(CHARTYPE *)"",FALSE);
  189. #ifdef TRACE
  190.     trace_return();
  191. #endif
  192.     return(RC_INVALID_ENVIRON);
  193.    }
  194. /*---------------------------------------------------------------------*/
  195. /* If no parameters, return without doing anything.                    */
  196. /*---------------------------------------------------------------------*/
  197.  if (CURRENT_VIEW->hex)
  198.    {
  199.     if ((len_params = convert_hex_strings(params)) == (-1))
  200.       {
  201.        display_error(32,(CHARTYPE *)"",FALSE);
  202. #ifdef TRACE
  203.        trace_return();
  204. #endif
  205.        return(RC_INVALID_OPERAND);
  206.       }
  207.    }
  208.  else
  209.    len_params = strlen(params);
  210.  for (i=0;i<len_params;i++)
  211.    {
  212.     real_key = case_translate((CHARTYPE)*(params+i));
  213.     chtype_key = (chtype)(real_key & A_CHARTEXT);
  214.     getyx(CURRENT_WINDOW,y,x);
  215. #if defined(USE_EXTCURSES)
  216.     attr = CURRENT_WINDOW->_a[y][x];
  217.     wattrset(CURRENT_WINDOW,attr);
  218.     attr = 0;
  219. #else
  220.     attr = winch(CURRENT_WINDOW) & A_ATTRIBUTES;
  221. #endif
  222.     switch(CURRENT_VIEW->current_window)
  223.       {
  224.        case WINDOW_MAIN:
  225.             if (CURRENT_SCREEN.sl[y].line_type != LINE_LINE)
  226.                break;
  227.             if (x+CURRENT_VIEW->verify_start > CURRENT_VIEW->verify_end)
  228.                break;
  229.             if (INSERTMODEx)
  230.               {
  231.                rec = meminschr(rec,real_key,CURRENT_VIEW->verify_col-1+x,
  232.                                max_line_length,rec_len);
  233.                put_char(CURRENT_WINDOW,chtype_key|attr,INSCHAR);
  234.               }
  235.             else
  236.               {
  237.                rec[CURRENT_VIEW->verify_col-1+x] = real_key;
  238.                if (x == CURRENT_SCREEN.cols[WINDOW_MAIN]-1)
  239.                   put_char(CURRENT_WINDOW,chtype_key|attr,INSCHAR);
  240.                else
  241.                   put_char(CURRENT_WINDOW,chtype_key|attr,ADDCHAR);
  242.               }
  243.             rc = memrevne(rec,' ',max_line_length);
  244.             if (rc == (-1))
  245.                rec_len = 0;
  246.             else
  247.                rec_len = rc+1;
  248.             /* check for the cursor moving past the right   */
  249.             /* margin when WORDWRAP is ON. If true, then    */
  250.             /* don't execute the cursor_right() function, as */
  251.             /* this could cause a window scroll.            */
  252.             if (CURRENT_VIEW->wordwrap
  253.             &&  rec_len > CURRENT_VIEW->margin_right)
  254.                execute_wrap_word(x+CURRENT_VIEW->verify_col);
  255.             else    
  256.                {
  257.                /* this is done here so that the show_page() in */
  258.                /* cursor_right() is executed AFTER we get the   */
  259.                /* new length of rec_len.                       */
  260. #if defined(USE_EXTCURSES)
  261.                if (x == CURRENT_SCREEN.cols[WINDOW_MAIN]-1)
  262.                  {
  263.                   wmove(CURRENT_WINDOW,y,x);
  264.      /*           wrefresh(CURRENT_WINDOW); */
  265.                   cursor_right(TRUE,FALSE);
  266.                  }
  267. #else
  268.                if (INSERTMODEx
  269.                || x == CURRENT_SCREEN.cols[WINDOW_MAIN]-1)
  270.                   cursor_right(TRUE,FALSE);
  271. #endif
  272.                }
  273. /*---------------------------------------------------------------------*/
  274. /* If HEXSHOW is on and we are on the current line, build screen...    */
  275. /*---------------------------------------------------------------------*/
  276.             if (CURRENT_VIEW->hexshow_on
  277.             &&  CURRENT_VIEW->focus_line == CURRENT_VIEW->current_line)
  278.                need_to_build_screen = TRUE;
  279.             break;
  280.        case WINDOW_COMMAND:
  281.             if (INSERTMODEx)
  282.               {
  283.                cmd_rec = (CHARTYPE *)meminschr((CHARTYPE *)cmd_rec,
  284.                                real_key,x,
  285.                                COLS,cmd_rec_len);
  286.                put_char(CURRENT_WINDOW,chtype_key,INSCHAR);
  287. #if !defined(USE_EXTCURSES)
  288.                cursor_right(TRUE,FALSE);
  289. #endif
  290.               }
  291.             else
  292.               {
  293.                cmd_rec[x] = real_key;
  294.                put_char(CURRENT_WINDOW,chtype_key,ADDCHAR);
  295.               }
  296.             rc = memrevne(cmd_rec,' ',COLS);
  297.             if (rc == (-1))
  298.                cmd_rec_len = 0;
  299.             else
  300.                cmd_rec_len = rc+1;
  301.             break;
  302.        case WINDOW_PREFIX:
  303.             if ((CURRENT_VIEW->prefix&PREFIX_LOCATION_MASK) == PREFIX_RIGHT
  304.             &&  prefix_width != PREFIX_WIDTH)
  305.                off = 1;
  306.             else
  307.                off = 0;
  308.             prefix_changed = TRUE;
  309.             if (pre_rec_len == 0)
  310.               {
  311.                wmove(CURRENT_WINDOW,y,off);
  312.                my_wclrtoeol(CURRENT_WINDOW);
  313.                wrefresh(CURRENT_WINDOW);
  314.                x = off;
  315.               }
  316.             if (INSERTMODEx)
  317.               {
  318.                pre_rec = (CHARTYPE *)meminschr((CHARTYPE *)pre_rec,
  319.                                real_key,x,
  320.                                PREFIX_WIDTH,pre_rec_len);
  321.                put_char(CURRENT_WINDOW,chtype_key,INSCHAR);
  322.               }
  323.             else
  324.               {
  325.                pre_rec[x] = real_key;
  326.                put_char(CURRENT_WINDOW,chtype_key,ADDCHAR);
  327.               }
  328.             wmove(CURRENT_WINDOW,y,min(x+1,(prefix_width-1)+off));
  329.             rc = memrevne(pre_rec,' ',PREFIX_WIDTH);
  330.             if (rc == (-1))
  331.                pre_rec_len = 0;
  332.             else
  333.                pre_rec_len = rc+1;
  334.             break;
  335.       }
  336.    }
  337. /*---------------------------------------------------------------------*/
  338. /* If text is being inserted on a line which is in the marked block,   */
  339. /* build and redisplay the window.                                     */
  340. /*---------------------------------------------------------------------*/
  341.  if (CURRENT_VIEW == MARK_VIEW
  342.  &&  CURRENT_VIEW->current_window == WINDOW_MAIN
  343.  &&  INSERTMODEx
  344.  &&  CURRENT_VIEW->focus_line >= MARK_VIEW->mark_start_line
  345.  &&  CURRENT_VIEW->focus_line <= MARK_VIEW->mark_end_line)
  346.      need_to_build_screen = TRUE;
  347.  if (need_to_build_screen)
  348.    {
  349.     build_current_screen();
  350.     display_current_screen();
  351.    }
  352. #ifdef TRACE
  353.  trace_return();
  354. #endif
  355.  return(RC_OK);
  356. }
  357. /*man-start*********************************************************************
  358. COMMAND
  359.      the - edit another file or switch to next file
  360.  
  361. SYNTAX
  362.      THE [filename]
  363.  
  364. DESCRIPTION
  365.      The THE command allows the user to edit another file. The new file
  366.      is placed in the file ring. The previous file being edited remains
  367.      in memory and can be returned to by issuing a THE command without
  368.      any parameters. Several files can be edited at once, and all files
  369.      are arranged in a ring, with subsequent THE commands moving through
  370.      the ring, one file at a time.
  371.  
  372. COMPATIBILITY
  373.      XEDIT: Does not provide options switches.
  374.      KEDIT: Does not provide options switches.
  375.  
  376. SEE ALSO
  377.      XEDIT, EDIT
  378.  
  379. STATUS
  380.      Complete.
  381. **man-end**********************************************************************/
  382.  
  383. /*man-start*********************************************************************
  384. COMMAND
  385.      top - move to the top of the file
  386.  
  387. SYNTAX
  388.      TOP
  389.  
  390. DESCRIPTION
  391.      The TOP command moves to the very start of the current file.
  392.      The "Top-of-file" line is set to the current_line.
  393.  
  394.      "TOP" is equivalent to "BACKWARD *".
  395.  
  396. COMPATIBILITY
  397.      XEDIT: Compatible.
  398.      KEDIT: Compatible.
  399.  
  400. SEE ALSO
  401.      BACKWARD, BOTTOM
  402.  
  403. STATUS
  404.      Complete
  405. **man-end**********************************************************************/
  406. #ifdef PROTO
  407. short Top(CHARTYPE *params)
  408. #else
  409. short Top(params)
  410. CHARTYPE *params;
  411. #endif
  412. /***********************************************************************/
  413. {
  414. /*-------------------------- external data ----------------------------*/
  415.  extern bool in_profile;
  416.  extern bool in_macro;
  417. /*--------------------------- local data ------------------------------*/
  418.  short rc=RC_TOF_EOF_REACHED;
  419.  unsigned short x=0,y=0;
  420. /*--------------------------- processing ------------------------------*/
  421. #ifdef TRACE
  422.  trace_function("comm5.c:   Top");
  423. #endif
  424. /*---------------------------------------------------------------------*/
  425. /* No arguments are allowed; error if any are present.                 */
  426. /*---------------------------------------------------------------------*/
  427.  if (strcmp(params,"") != 0)
  428.    {
  429.     display_error(1,(CHARTYPE *)params,FALSE);
  430. #ifdef TRACE
  431.     trace_return();
  432. #endif
  433.     return(RC_INVALID_OPERAND);
  434.    }
  435.  CURRENT_VIEW->current_line = 0L;
  436.  post_process_line(CURRENT_VIEW,CURRENT_VIEW->focus_line);
  437.  build_current_screen(); 
  438.  if (!line_in_view(CURRENT_VIEW->focus_line))
  439.     CURRENT_VIEW->focus_line = 0L;
  440.  pre_process_line(CURRENT_VIEW,CURRENT_VIEW->focus_line);
  441.  if (!in_profile && !in_macro)
  442.    {
  443.     if (CURRENT_VIEW->current_window == WINDOW_COMMAND)
  444.        getyx(PREVIOUS_WINDOW,y,x);
  445.     else
  446.        getyx(CURRENT_WINDOW,y,x);
  447.     display_current_screen();
  448.     y = get_row_for_focus_line(CURRENT_VIEW->focus_line,
  449.                                CURRENT_VIEW->current_row);
  450.     if (CURRENT_VIEW->current_window == WINDOW_COMMAND)
  451.        wmove(PREVIOUS_WINDOW,y,x);
  452.     else
  453.        wmove(CURRENT_WINDOW,y,x);
  454.    }
  455. #ifdef TRACE
  456.  trace_return();
  457. #endif
  458.  return(rc);
  459. }
  460. /*man-start*********************************************************************
  461. COMMAND
  462.      up - move backward in the file a number of lines
  463.  
  464. SYNTAX
  465.      Up [relative_target]
  466.  
  467. DESCRIPTION
  468.      The UP command moves the current line backwards the number of
  469.      lines specified by the relative_target. This relative_target can 
  470.      only be a positive integer or the character "*". 
  471.  
  472. COMPATIBILITY
  473.      XEDIT: Compatible.
  474.      KEDIT: Compatible.
  475.  
  476. DEFAULT
  477.      1
  478.  
  479. SEE ALSO
  480.      NEXT, DOWN
  481.  
  482. STATUS
  483.      Complete.
  484. **man-end**********************************************************************/
  485. #ifdef PROTO
  486. short Up(CHARTYPE *params)
  487. #else
  488. short Up(params)
  489. CHARTYPE *params;
  490. #endif
  491. /***********************************************************************/
  492. {
  493. /*-------------------------- external data ----------------------------*/
  494.  extern bool curses_started;
  495. /*--------------------------- local data ------------------------------*/
  496.  unsigned short y=0,x=0;
  497.  short rc=RC_OK;
  498.  LINE *curr=NULL;
  499.  LINETYPE num_lines=0L,true_line=0L;
  500. /*--------------------------- processing ------------------------------*/
  501. #ifdef TRACE
  502.  trace_function("comm5.c:   Up");
  503. #endif
  504.  if (strcmp("",params) == 0)
  505.     params = (CHARTYPE *)"1";
  506.  true_line = get_true_line();
  507.  if (strcmp("*",params) == 0)
  508.     num_lines = true_line + 1L;
  509.  else
  510.    {
  511.     if (!valid_integer(params))
  512.       {
  513.        display_error(4,params,FALSE);
  514. #ifdef TRACE
  515.        trace_return();
  516. #endif
  517.        return(RC_INVALID_OPERAND);
  518.       }
  519.     num_lines = atol(params);
  520.     if (num_lines < 0L)
  521.       {
  522.        display_error(5,params,FALSE);
  523. #ifdef TRACE
  524.        trace_return();
  525. #endif
  526.        return(RC_INVALID_OPERAND);
  527.       }
  528.    }
  529.  if (CURRENT_VIEW->current_window == WINDOW_COMMAND)
  530.     rc = advance_current_line(-num_lines);
  531.  else
  532.     rc = advance_focus_line(-num_lines);
  533. #ifdef TRACE
  534.  trace_return();
  535. #endif
  536.  return(rc);
  537. }
  538. /*man-start*********************************************************************
  539. COMMAND
  540.      uppercase - change lowercase characters to uppercase
  541.  
  542. SYNTAX
  543.      UPPercase [target]
  544.  
  545. DESCRIPTION
  546.      The UPPERCASE command changes all lowercase characters in all
  547.      lines up to the target line to uppercase. All other characters 
  548.      remain untouched.
  549.  
  550. COMPATIBILITY
  551.      XEDIT: Equivalent of UPPERCAS
  552.      KEDIT: Compatible.
  553.  
  554. SEE ALSO
  555.      LOWERCASE
  556.  
  557. STATUS
  558.      Complete.
  559. **man-end**********************************************************************/
  560. #ifdef PROTO
  561. short Uppercase(CHARTYPE *params)
  562. #else
  563. short Uppercase(params)
  564. CHARTYPE *params;
  565. #endif
  566. /***********************************************************************/
  567. {
  568. /*--------------------------- local data ------------------------------*/
  569.  short rc=RC_OK;
  570. /*--------------------------- processing ------------------------------*/
  571. #ifdef TRACE
  572.  trace_function("comm3.c:   Uppercase");
  573. #endif
  574.  rc = execute_change_case(params,CASE_UPPER);
  575. #ifdef TRACE
  576.  trace_return();
  577. #endif
  578.  return(rc);
  579. }
  580. /*man-start*********************************************************************
  581. COMMAND
  582.      xedit - edit another file or switch to next file
  583.  
  584. SYNTAX
  585.      Xedit [filename]
  586.  
  587. DESCRIPTION
  588.      The XEDIT command allows the user to edit another file. The new file
  589.      is placed in the file ring. The previous file being edited remains
  590.      in memory and can be returned to by issuing an XEDIT command without
  591.      any parameters. Several files can be edited at once, and all files
  592.      are arranged in a ring, with subsequent XEDIT commands moving through
  593.      the ring, one file at a time.
  594.  
  595. COMPATIBILITY
  596.      XEDIT: Does not provide options switches.
  597.      KEDIT: Does not provide options switches.
  598.  
  599. SEE ALSO
  600.      EDIT, THE
  601.  
  602. STATUS
  603.      Complete.
  604. **man-end**********************************************************************/
  605. #ifdef PROTO
  606. short Xedit(CHARTYPE *params)
  607. #else
  608. short Xedit(params)
  609. CHARTYPE *params;
  610. #endif
  611. /***********************************************************************/
  612. {
  613. /*-------------------------- external data ----------------------------*/
  614.  extern VIEW_DETAILS *vd_first;
  615.  extern CHARTYPE *cmd_rec;
  616.  extern unsigned short cmd_rec_len;
  617.  extern bool REPROFILEx;
  618.  extern CHARTYPE number_of_files;
  619.  extern CHARTYPE *prf_arg;
  620.  extern short file_start;
  621.  extern CHARTYPE *dirfilename;
  622.  extern bool curses_started;
  623.  extern bool execute_profile;
  624.  extern bool in_profile;
  625.  extern CHARTYPE display_screens;
  626.  extern WINDOW *foot;
  627.  extern WINDOW *divider;
  628.  extern bool horizontal;
  629. /*--------------------------- local data ------------------------------*/
  630.  short rc=RC_OK;
  631.  int y=0,x=0;
  632.  VIEW_DETAILS *save_current_view=NULL;
  633.  VIEW_DETAILS *previous_current_view=NULL;
  634.  bool two_views_of_same_file=FALSE;
  635. /*--------------------------- processing ------------------------------*/
  636. #ifdef TRACE
  637.  trace_function("comm5.c:   Xedit");
  638. #endif
  639. /*---------------------------------------------------------------------*/
  640. /* Before we do anything, determine if there are 2 views of the same   */
  641. /* file being displayed...                                             */
  642. /*---------------------------------------------------------------------*/
  643.  if (number_of_files > 0
  644.  &&  display_screens > 1
  645.  &&  CURRENT_SCREEN.screen_view->file_for_view == OTHER_SCREEN.screen_view->file_for_view)
  646.     two_views_of_same_file = TRUE;
  647. /*---------------------------------------------------------------------*/
  648. /* With no arguments, edit the next file in the ring...                */
  649. /*---------------------------------------------------------------------*/
  650.  if (strcmp(params,"") == 0)
  651.    {
  652. /*---------------------------------------------------------------------*/
  653. /* If this is the only file, ignore the command...                     */
  654. /*---------------------------------------------------------------------*/
  655.     if (number_of_files < 2)
  656.       {
  657. #ifdef TRACE
  658.        trace_return();
  659. #endif
  660.        return(RC_OK);
  661.       }
  662.     memset(cmd_rec,' ',COLS);
  663.     cmd_rec_len = 0;
  664.     post_process_line(CURRENT_VIEW,CURRENT_VIEW->focus_line);
  665. /*---------------------------------------------------------------------*/
  666. /* If more than one screen is displayed and the file displayed in each */
  667. /* screen is the same, remove the 'current' view from the linked list. */
  668. /*---------------------------------------------------------------------*/
  669.     if (two_views_of_same_file)
  670.       {
  671.        save_current_view = CURRENT_VIEW;
  672.        free_a_view();
  673.        CURRENT_FILE->file_views--;
  674.        CURRENT_SCREEN.screen_view = CURRENT_VIEW;
  675.       }
  676. /*---------------------------------------------------------------------*/
  677. /* Save the position of the cursor for the current view before getting */
  678. /* the contents of the new file...                                     */
  679. /*---------------------------------------------------------------------*/
  680.     if (curses_started)
  681.       {
  682.        if (CURRENT_WINDOW_COMMAND != NULL)
  683.          {
  684.           wmove(CURRENT_WINDOW_COMMAND,0,0);
  685.           my_wclrtoeol(CURRENT_WINDOW_COMMAND);
  686.          }
  687.        getyx(CURRENT_WINDOW_MAIN,CURRENT_VIEW->y[WINDOW_MAIN],CURRENT_VIEW->x[WINDOW_MAIN]);
  688.        if (CURRENT_WINDOW_PREFIX != NULL)
  689.           getyx(CURRENT_WINDOW_PREFIX,CURRENT_VIEW->y[WINDOW_PREFIX],CURRENT_VIEW->x[WINDOW_PREFIX]);
  690.       }
  691. /*---------------------------------------------------------------------*/
  692. /* Make the next view the current view...                              */
  693. /*---------------------------------------------------------------------*/
  694.     save_current_view = CURRENT_VIEW;
  695.     if (CURRENT_VIEW->next == (VIEW_DETAILS *)NULL)
  696.        CURRENT_VIEW = vd_first;
  697.     else
  698.        CURRENT_VIEW = CURRENT_VIEW->next;
  699.     CURRENT_SCREEN.screen_view = CURRENT_VIEW;
  700.     if ((save_current_view->prefix&PREFIX_LOCATION_MASK)
  701.          != (CURRENT_VIEW->prefix&PREFIX_LOCATION_MASK)
  702.     ||  save_current_view->cmd_line != CURRENT_VIEW->cmd_line
  703.     ||  save_current_view->id_line != CURRENT_VIEW->id_line)
  704.       {
  705. /*---------------------------------------------------------------------*/
  706. /* If the position of the prefix or command line for the new view is   */
  707. /* different from the previous view, rebuild the windows...            */
  708. /*---------------------------------------------------------------------*/
  709.        set_screen_defaults();
  710.        if (curses_started)
  711.          {
  712.           if (set_up_windows(current_screen) != RC_OK)
  713.             {
  714. #ifdef TRACE
  715.             trace_return();
  716. #endif
  717.             return(RC_OK);
  718.            }
  719.          }
  720.       }
  721.     pre_process_line(CURRENT_VIEW,CURRENT_VIEW->focus_line);
  722.     build_current_screen(); 
  723.     display_current_screen();
  724.     if (curses_started)
  725.       {
  726.        if (foot != NULL)
  727.          {
  728.           wattrset(foot,set_colour(CURRENT_FILE->attr+ATTR_STATAREA));
  729.           redraw_window(foot);
  730.           touchwin(foot);
  731.          }
  732.        if (divider != NULL)
  733.          {
  734.           if (display_screens > 1
  735.           && !horizontal)
  736.             {
  737. #ifdef A_ALTCHARSET
  738.              wattrset(divider,A_ALTCHARSET|set_colour(CURRENT_FILE->attr+ATTR_DIVIDER));
  739. #else
  740.              wattrset(divider,set_colour(CURRENT_FILE->attr+ATTR_DIVIDER));
  741. #endif
  742.              redraw_window(divider);
  743.              touchwin(divider);
  744.              wnoutrefresh(divider);
  745.             }
  746.          }
  747.        wmove(CURRENT_WINDOW_MAIN,CURRENT_VIEW->y[WINDOW_MAIN],CURRENT_VIEW->x[WINDOW_MAIN]);
  748.        if (CURRENT_WINDOW_PREFIX != NULL)
  749.           wmove(CURRENT_WINDOW_PREFIX,CURRENT_VIEW->y[WINDOW_PREFIX],CURRENT_VIEW->x[WINDOW_PREFIX]);
  750.        getyx(CURRENT_WINDOW,y,x);
  751.        wmove(CURRENT_WINDOW,y,x);
  752.       }
  753. #ifdef TRACE
  754.     trace_return();
  755. #endif
  756.     return(RC_OK);
  757.    }
  758. /*---------------------------------------------------------------------*/
  759. /* If there are still file(s) in the ring, clear the command line and  */
  760. /* save any changes to the focus line.                                 */
  761. /*---------------------------------------------------------------------*/
  762.  if (number_of_files > 0)
  763.    {
  764.     post_process_line(CURRENT_VIEW,CURRENT_VIEW->focus_line);
  765.     memset(cmd_rec,' ',COLS);
  766.     cmd_rec_len = 0;
  767.     previous_current_view = CURRENT_VIEW;
  768.    }
  769. /*---------------------------------------------------------------------*/
  770. /* Save the position of the cursor for the current view before getting */
  771. /* the contents of the new file...                                     */
  772. /*---------------------------------------------------------------------*/
  773.  if (curses_started
  774.  &&  number_of_files > 0)
  775.    {
  776.     if (CURRENT_WINDOW_COMMAND != NULL)
  777.       {
  778.        wmove(CURRENT_WINDOW_COMMAND,0,0);
  779.        my_wclrtoeol(CURRENT_WINDOW_COMMAND);
  780.       }
  781.     getyx(CURRENT_WINDOW_MAIN,CURRENT_VIEW->y[WINDOW_MAIN],CURRENT_VIEW->x[WINDOW_MAIN]);
  782.     if (CURRENT_WINDOW_PREFIX != NULL)
  783.        getyx(CURRENT_WINDOW_PREFIX,CURRENT_VIEW->y[WINDOW_PREFIX],CURRENT_VIEW->x[WINDOW_PREFIX]);
  784.    }
  785. /*---------------------------------------------------------------------*/
  786. /* Read the contents of the new file into memory...                    */
  787. /*---------------------------------------------------------------------*/
  788.  if ((rc = get_file(strtrans(params,OSLASH,ISLASH))) != RC_OK)
  789.    {
  790. #ifdef TRACE
  791.     trace_return();
  792. #endif
  793.     return(rc);
  794.    }
  795. /*---------------------------------------------------------------------*/
  796. /* If more than one screen is displayed and the file displayed in each */
  797. /* screen is the same, remove the 'current' view from the linked list. */
  798. /*---------------------------------------------------------------------*/
  799.  if (two_views_of_same_file)
  800.    {
  801.     save_current_view = CURRENT_VIEW;
  802.     CURRENT_VIEW = previous_current_view;
  803.     CURRENT_FILE->file_views--;
  804.     free_a_view();
  805.     CURRENT_SCREEN.screen_view = CURRENT_VIEW = save_current_view;
  806.    }
  807.  pre_process_line(CURRENT_VIEW,CURRENT_VIEW->focus_line);
  808.  if (REPROFILEx && !in_profile)
  809.    {
  810.     in_profile = TRUE;
  811.     if (execute_profile)
  812.        (void)get_profile(prf_arg);
  813.     in_profile = FALSE;
  814.    }
  815.  pre_process_line(CURRENT_VIEW,CURRENT_VIEW->focus_line);
  816.  build_current_screen();
  817. /*---------------------------------------------------------------------*/
  818. /* If curses hasn't started, don't try to use curses functions...      */
  819. /*---------------------------------------------------------------------*/
  820.  if (curses_started)
  821.    {
  822.     display_current_screen();
  823.     if (strcmp(CURRENT_FILE->fname,dirfilename) == 0)
  824.        wmove(CURRENT_WINDOW_MAIN,CURRENT_VIEW->current_row,file_start-1);
  825.     else
  826.        wmove(CURRENT_WINDOW_MAIN,CURRENT_VIEW->current_row,0);
  827.     wmove(CURRENT_WINDOW_COMMAND,0,0);
  828.     if (CURRENT_WINDOW_PREFIX != NULL)
  829.        touchwin(CURRENT_WINDOW_PREFIX);
  830.     if (CURRENT_WINDOW_COMMAND != NULL)
  831.        touchwin(CURRENT_WINDOW_COMMAND);
  832.     if (CURRENT_WINDOW_IDLINE != NULL)
  833.        touchwin(CURRENT_WINDOW_IDLINE);
  834.     touchwin(CURRENT_WINDOW_MAIN);
  835.    }
  836. #ifdef TRACE
  837.  trace_return();
  838. #endif
  839.  return(rc);
  840. }
  841. /*man-start*********************************************************************
  842. COMMAND
  843.      retrieve - return the next/prior command on the command line
  844.  
  845. SYNTAX
  846.      ?[+]
  847.  
  848. DESCRIPTION
  849.      The ? command returns the next or prior command from the command
  850.      line stack and displays it on the command line.
  851.      With no parameters, the most recent command entered on the command
  852.      line is retrieved.
  853.  
  854. COMPATIBILITY
  855.      XEDIT: Compatible.
  856.      KEDIT: See below..
  857.      Does not support multiple '?' as in ??? to retrieve the third last
  858.      command.
  859.      This command is bound to the up and down arrows when on the
  860.      command line depending on the setting of CMDARROWS.
  861.  
  862. SEE ALSO
  863.      SET CMDARROWS
  864.  
  865. STATUS
  866.      Complete.
  867. **man-end**********************************************************************/
  868. #ifdef PROTO
  869. short Retrieve(CHARTYPE *params)
  870. #else
  871. short Retrieve(params)
  872. CHARTYPE *params;
  873. #endif
  874. /***********************************************************************/
  875. {
  876. /*-------------------------- external data ----------------------------*/
  877. /*--------------------------- local data ------------------------------*/
  878.  CHARTYPE *current_command=NULL;
  879. /*--------------------------- processing ------------------------------*/
  880. #ifdef TRACE
  881.  trace_function("comm4.c:   Retrieve");
  882. #endif
  883.  if (strcmp(params,"") == 0)
  884.    {
  885.     current_command = get_next_command(DIRECTION_FORWARD);
  886.     current_command = get_next_command(DIRECTION_FORWARD);
  887.    }
  888.  else
  889.     if (strcmp(params,"+") == 0)
  890.       current_command = get_next_command(DIRECTION_BACKWARD);
  891.     else
  892.       {
  893.        display_error(1,params,FALSE);
  894. #ifdef TRACE
  895.        trace_return();
  896. #endif
  897.        return(RC_INVALID_OPERAND);
  898.       }
  899.  
  900.  wmove(CURRENT_WINDOW_COMMAND,0,0);
  901.  my_wclrtoeol(CURRENT_WINDOW_COMMAND);
  902.  if (current_command != (CHARTYPE *)NULL)
  903.     Cmsg(current_command);
  904. #ifdef TRACE
  905.  trace_return();
  906. #endif
  907.  return(RC_OK);
  908. }
  909. /*man-start*********************************************************************
  910. COMMAND
  911.      = - re-execute the last command issued on the command line
  912.  
  913. SYNTAX
  914.      =
  915.  
  916. DESCRIPTION
  917.      The = command retrieves the most recently issued command from
  918.      the command line and re-executes it.
  919.  
  920. COMPATIBILITY
  921.      XEDIT: Does not support optional [subcommand] option.
  922.      KEDIT: Does not support optional [command] option.
  923.  
  924. STATUS
  925.      Complete.
  926. **man-end**********************************************************************/
  927. #ifdef PROTO
  928. short Reexecute(CHARTYPE *params)
  929. #else
  930. short Reexecute(params)
  931. CHARTYPE *params;
  932. #endif
  933. /***********************************************************************/
  934. {
  935. /*--------------------------- local data ------------------------------*/
  936.  CHARTYPE *current_command=NULL;
  937.  short rc=RC_OK;
  938. /*--------------------------- processing ------------------------------*/
  939. #ifdef TRACE
  940.  trace_function("comm4.c:   Reexecute");
  941. #endif
  942.  if (strcmp(params,""))
  943.     {
  944.      display_error(1,params,FALSE);
  945. #ifdef TRACE
  946.      trace_return();
  947. #endif
  948.      return(RC_INVALID_OPERAND);
  949.     }
  950. /*---------------------------------------------------------------------*/
  951. /* Retrieve the last command and execute it.                           */
  952. /*---------------------------------------------------------------------*/
  953.  current_command = get_next_command(DIRECTION_NONE);
  954.  if (current_command != NULL)
  955.     rc = command_line(current_command,COMMAND_ONLY_FALSE);
  956. #ifdef TRACE
  957.  trace_return();
  958. #endif
  959.  return(rc);
  960. }
  961. /*man-start*********************************************************************
  962. COMMAND
  963.      ! - execute an operating system command
  964.  
  965. SYNTAX
  966.      ! [command]
  967.  
  968. DESCRIPTION
  969.      The OS command executes the supplied operating system command 
  970.      or runs an interactive shell if no command is supplied.
  971.  
  972. COMPATIBILITY
  973.      XEDIT: N/A
  974.      KEDIT: Equivalent to DOS command.
  975.  
  976. SEE ALSO
  977.      DOS, OS
  978.  
  979. STATUS
  980.      Complete.
  981. **man-end**********************************************************************/
  982.